<?php
namespace app\index\model;

use think\Db;
use think\Model;

class CameraManager extends Model {
    public function __construct()
    {
    }

    public function readAllCamera(){
        return Db::query("select * from cream");
    }

    public function readCameraByFarm($id){
        return Db::query("select * from cream where user_id=".$id);
    }

    public function readCamera($id){
        return Db::query("select * from cream where cream_id=".$id)[0];
    }

    public function deleteCamera($id){
        return Db::table("cream")->where("cream_id",$id)->delete();
    }

    public function createCamera($farmInfo){
        return Db::table("cream")->insert($farmInfo);
    }

    public function updateCamera($id,$farmInfo){
        return Db::table("cream")->where("cream_id",$id)->update($farmInfo);
    }
}